package com.hq.fxh.No5_User.MyModle.Activity.item;

import android.text.InputFilter;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/8/30
 * @Email xlwenhao1858@sina.com
 */

public class EmojiFilter implements InputFilter {

    private static final String TAG = "EmojiFilter";


    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
        StringBuffer buffer = new StringBuffer();
        for (int i = start; i < end; i++) {
            char c = source.charAt(i);
            // 第一个字符为以下时，过滤掉
            if (c == 55356 || c == 55357 || c == 10060 || c == 9749 || c == 9917 || c == 10067 || c == 10024
                    || c == 11088 || c == 9889 || c == 9729 || c == 11093 || c == 9924) {
                i++;
                continue;
            } else {
                buffer.append(c);
            }
        }
        if (source instanceof Spanned) {
            SpannableString sp = new SpannableString(buffer);
            TextUtils.copySpansFrom((Spanned) source, start, end, null, sp, 0);
            return sp;
        } else {
            return buffer;
        }
    }


}
